<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <!--<script type="text/javascript" src="./js/xadmin.js"></script>-->
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>-->
    <!--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>-->
    <!--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>-->
    <!--[endif]-->
    <script type="text/javascript" src="../../common/js/public.js"></script>
    <script type="text/javascript" src="../../common/js/publicUtils.js"></script>
    <style>
        .menudiv .layui-input-inline,.buttondiv .layui-input-inline {
            float: left;
            width: 450px !important;
            margin-right: 10px;
        }
        .buttondiv{
            display: none;
        }

    </style>
</head>
<body >
<div class="layui-fluid" id="flowDiv" onload="onLoad()" >
    <div class="zTreeBackground left" style="float: left;width:100%">
        <div class="titlediv">
            <p style="text-align:center;width:100%;background-color:white;line-height: 30px">专业领域信息</p>
        </div>
        <div class="searchdiv">
            <div class="layui-input-inline" style="width: 100%">
                <input type="search" id="keyword" name="keyword" autocomplete="off" class="layui-input" placeholder="请输入关键字查询"/>
                <i onclick="query()" class="layui-icon layui-icon-search" style="position: absolute;top:8px;right: 8px;"></i>
            </div>
        </div>
        <div class="ztreediv" id="ztreediv" style="padding-left: 5%;overflow:auto">
            <ul id="treeStructure" class="ztree"></ul>
        </div>
    </div>
</div>
</body>
<SCRIPT type="text/javascript">
    var zTreeObj,zTreeObj_input,zTreeObj_input_button;
    var form;
    var table;

    layui.use(['form', 'layer'], function() {
        form = layui.form;
        layer = layui.layer;
        table = layui.table;
    })
    var id=getUrlParam('id');
    var disciplinesId='';
    var disciplinesType='';
    $(document).ready(function(){
        loadTree();
    });


    window.onload = getContentSize;
    window.onresize = getContentSize;

    /**
     * 点击触发
     * @param event
     * @param treeId
     * @param treeNode
     */
    function zTreeOnClick(event, treeId, treeNode) {
        disciplinesId=treeNode.id;
        disciplinesType=treeNode.type;
    }

    /**
     * 保存
     */
    function submit(index, layero,type){
        if(disciplinesType!=2){
            layer.msg("请选择专业");
            return;
        }
        var result;
        publicAjax (null,'resEntElementTree/moveResEntElementTreeByID',{id:id,disciplinesId:disciplinesId},false,null,function (r) {
            result=r;
        })
        if(type=='applye'){
            if(result.code==2000){
                laysuccess("移动成功");
            }else{
                layerror("移动失败");
            }
        }
        return result;

    }

    /**
     *
     */
    function getContentSize() {
        var wh = document.documentElement.clientHeight;
        var eh = 30;
        ch = (wh - eh) + "px";
        document.getElementById( "flowDiv" ).style.height = ch;
        document.getElementById( "ztreediv" ).style.height = (wh - eh - 50)+"px";
        document.body.style.height = (wh)+"px";
    }




    /**
     * 左侧树设置
     * @type
     */
    var setting = {
        check: {
            enable: false
        },
        edit:{
            enable: false,
        },
        data: {
            simpleData: {
                enable: true,
                idKey:"id",
                pIdKey:"pid",
                isParent:"parent",
                rootPid:-1
            },
            key: {
                url: "xUrl",
                icon:"xIcon"
            }
        },
        callback: {
            onClick: zTreeOnClick
        }
    };





    /**
     * 模糊查询
     */
    function query(){
        loadTree($("#keyword").val(),$("#keyword").val()==""?0:1);
    }

    /**
     * 加载左侧树
     * type 0:不展开节点
     *      1:展开全部节点
     *
     */
    function loadTree(keyWord,type){
        publicAjax (null,'infDisciplines/selectAllInfDisciplinesByTree',{name: keyWord},null,null,function (r) {
            var jsondata = r.data;
            var json = {"id":-1,"name":"专业领域", open:true};
            jsondata.push(json);
            zTreeObj = $.fn.zTree.init($("#treeStructure"), setting, jsondata);
            if(type==1){
                zTreeObj.expandAll(true);
            }
        })
    }



    function isEmpty(value) {
        if (value == null || this.trim(value) == "") {
            return true;
        }
        return false;
    }

    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }



</SCRIPT>
</html>